﻿using System;
using System.Collections.Generic;
using BlockLogic.Impl.Controller;
using CommandLogic.Interface;
using BlockLogic.Impl.Enum;
using BlockLogic.Impl.Factory;

namespace CommandLogic.Impl
{
    public class CreateBlockCommand : ICommandLogic
    {
        private static CreateBlockCommand instance = new CreateBlockCommand();

        private CreateBlockCommand(){}

        public static CreateBlockCommand GetInstance()
        {
            return instance;
        }

        public Dictionary<string, object> execute(Dictionary<string, object> param)
        {
            var blockType = (BlockType) (Enum.Parse(typeof(BlockType), param["blocktype"].ToString()));
            var id = (Guid) param["id"];

            var factory = BlockFactory.GetInstance();
            var block = factory.Create(id, blockType);

            var blockController = BlockController.GetInstance();
            blockController.AddBlock(block);

            return null;
        }
    }
}
